from camel.agents import ChatAgent
from camel.models import ModelFactory
from camel.types import ModelPlatformType
from camel.messages import BaseMessage
from camel.types import RoleType
from camel.memories import ChatHistoryBlock
from dotenv import load_dotenv
import os
load_dotenv()

# 使用简单的列表来管理对话历史

Model_Type=os.getenv("MODEL_TYPE")
Model_Api=os.getenv("ZHIPU_API_KEY")
Model_Url=os.getenv("MODEL_URL")
model = ModelFactory.create(
    model_platform=ModelPlatformType.OPENAI,
    model_type=Model_Type,
    api_key=Model_Api,
    url=Model_Url
)
#创建对话历史块
history_block = ChatHistoryBlock()

print(f'现在多少记录: {len(history_block.messages)}')

#添加用户消息
user_msg = BaseMessage(
    role_name="患者",
    role_type=RoleType.USER,
    meta_dict={},
    content="医生，我头疼"
)

#添加消息到历史记录
history_block.add_message(user_msg)

print(f'现在多少记录: {len(history_block.messages)}')

